/*
 * @Author: huangyq
 * @Date: 2022/2/11 下午4:57
 * @Last Modified by: huangyq
 * @Last Modified time: 2022/2/11 下午4:57
 * @Desc
 */

import { ElForm } from 'element-plus/es'

export const submitForm = (
  formEl: InstanceType<typeof ElForm>
): Promise<boolean> => {
  return new Promise(resolve => {
    if (!formEl) resolve(false)
    formEl.validate(valid => {
      if (valid) {
        resolve(true)
        return true
      } else {
        resolve(false)
        return false
      }
    })
  })
}

export const resetForm = (formEl: InstanceType<typeof ElForm>): void => {
  if (!formEl) return
  formEl.resetFields()
}
